package de.baumann.browser.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import de.baumann.browser.R
import de.baumann.browser.api.net.vo.Rank
import de.baumann.browser.utils.StringUtil


class ProPlanAdapter : BaseQuickAdapter<Rank, BaseViewHolder>(R.layout.item_rank) {
    override fun convert(helper: BaseViewHolder, item: Rank?) {
        if (item == null) {
            return
        }
        helper.setText(R.id.rankNum, "${helper.layoutPosition + 1}")
        var userAddress = item.userAddress
        if (userAddress == null) {
            userAddress = "**"
        } else {
            userAddress = replace(userAddress)
        }
        helper.setText(R.id.rankName, userAddress)
        helper.setText(R.id.rankHash, item.power)
    }

    fun replace(str: String): String {
        return str.replace(str.substring(4, str.length - 6), "****")
    }
}